﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SampleApp.Domain;
using COM.Data;


namespace SampleApp.Data
{
    public interface ISysUserRepository : IRepository<SysUser>
    {
        SysUser GetUserWithRoleList(string userCode);
    }

    public class SysUserRepository : AnyRepositoryBase<SysUser>, ISysUserRepository
    {
        public SysUserRepository(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
        {
        }

        public SysUser GetUserWithRoleList(string userCode)
        {
            var user = this.GetByID(userCode);
            this.DataContext.Entry(user).Collection(i => i.UserRoleList).Load();
            return user;
        }

    }


}
